Imports System.Collections.ObjectModel
Imports OMANE.Common.Model.Interfaces
Imports Actuariat
Imports PTIC_GestionBDD

Public Class TableMaintienINCINVFromDataTable
    Implements ITableMaintienINCAPINVAL

    Private m_MaintienINCINV As DataTable
    Private m_AgeMin As Integer
    Private m_AgeMax As Integer
    Private m_MoisMin As Integer
    Private m_MoisMax As Integer

    Public Sub New(ByVal Nom As String, ByVal DTTble As DataTable)
        m_Nom = Nom
        m_MaintienINCINV = DTTble
        With DTTble.Columns
            m_AgeMin = CInt(Right(.Item(1).ColumnName, .Item(1).ColumnName.Length - 1))
            m_AgeMax = CInt(Right(.Item(.Count - 1).ColumnName, .Item(.Count - 1).ColumnName.Length - 1))
            m_MoisMin = 0
            m_MoisMax = DTTble.Rows.Count - 1
        End With
    End Sub

    Public Function Proba_Maintien(ByVal nbMois As Integer, ByVal ageSurv As Integer) As Double Implements Actuariat.ITableMaintienINCAPINVAL.Proba_Maintien
        Dim result As Double = 0
        If ageSurv >= 20 And ageSurv <= 65 And nbMois <= 601 Then
            Dim x1 As Double = m_MaintienINCINV.Rows(nbMois)("A" & (ageSurv))
            Dim x2 As Double = m_MaintienINCINV.Rows(0)("A" & (ageSurv))
            result = x1 / x2
        End If
        Return result
    End Function

    Private m_Nom As String
    Public ReadOnly Property Nom As String Implements Actuariat.ITableTravail.Nom
        Get
            Return m_Nom
        End Get
    End Property
End Class